From ab5301ae22a167a9ffbfeda0ab48362e92fee7b6 Mon Sep 17 00:00:00 2001 From: "rneugeba@wyvis.research.intel-research.net" Date: Thu, 10 Mar 2005 18:12:10 +0000 Subject: [PATCH] bitkeeper revision 1.1244 (42308dfaWqh7O5QB-sS9WJ1R4LYoEA) various hacks for batching mode and stats gathering Signed-off-by: michael.fetterman@cl.cam.ac.uk --- .rootkeys | 2 + linux-2.6.10-xen-sparse/arch/xen/Kconfig | 31 ++++++- .../arch/xen/i386/kernel/Makefile | 2 + .../arch/xen/i386/kernel/entry.S | 10 +- .../arch/xen/i386/kernel/syscall_stats.c | 91 +++++++++++++++++++ .../arch/xen/i386/mm/hypervisor.c | 3 + .../include/asm-xen/asm-i386/pgtable-2level.h | 9 ++ linux-2.6.10-xen-sparse/mm/memory.c | 50 +++++++++- tools/misc/Makefile | 2 +- tools/misc/cpuperf/cpuperf.c | 2 +- tools/misc/xc_shadow.c | 70 ++++++++++++++ 11 files changed, 266 insertions(+), 6 deletions(-) create mode 100644 linux-2.6.10-xen-sparse/arch/xen/i386/kernel/syscall_stats.c create mode 100644 tools/misc/xc_shadow.c diff --git a/.rootkeys b/.rootkeys index b7b65f0953..e4a6475151 100644 --- a/.rootkeys +++ b/.rootkeys @@ -159,6 +159,7 @@ 40f56238nWMQg7CKbyTy0KJNvCzbtg linux-2.6.10-xen-sparse/arch/xen/i386/kernel/signal.c 41811cac4lkCB-fHir6CcxuEJ2pGsQ linux-2.6.10-xen-sparse/arch/xen/i386/kernel/smp.c 41811ca9mbGpqBrZVrUGEiv8CTV3ng linux-2.6.10-xen-sparse/arch/xen/i386/kernel/smpboot.c +42308df8u332Gs7XX-jX4gsfFU2zOQ linux-2.6.10-xen-sparse/arch/xen/i386/kernel/syscall_stats.c 40f56238qVGkpO_ycnQA8k03kQzAgA linux-2.6.10-xen-sparse/arch/xen/i386/kernel/time.c 40f56238NzTgeO63RGoxHrW5NQeO3Q linux-2.6.10-xen-sparse/arch/xen/i386/kernel/timers/Makefile 40f56238BMqG5PuSHufpjbvp_helBw linux-2.6.10-xen-sparse/arch/xen/i386/kernel/timers/timer_tsc.c @@ -601,6 +602,7 @@ 40c9c469kT0H9COWzA4XzPBjWK0WsA tools/misc/netfix 4022a73cEKvrYe_DVZW2JlAxobg9wg tools/misc/nsplitd/Makefile 4022a73cKms4Oq030x2JBzUB426lAQ tools/misc/nsplitd/nsplitd.c +42308df9dv_ZuP49nNPIROEMQ3F_LA tools/misc/xc_shadow.c 3f5ef5a2ir1kVAthS14Dc5QIRCEFWg tools/misc/xen-clone 3f5ef5a2dTZP0nnsFoeq2jRf3mWDDg tools/misc/xen-clone.README 405eedf6_nnNhFQ1I85lhCkLK6jFGA tools/misc/xencons diff --git a/linux-2.6.10-xen-sparse/arch/xen/Kconfig b/linux-2.6.10-xen-sparse/arch/xen/Kconfig index 2a8c5f200f..47e508cdc1 100644 --- a/linux-2.6.10-xen-sparse/arch/xen/Kconfig +++ b/linux-2.6.10-xen-sparse/arch/xen/Kconfig @@ -115,9 +115,38 @@ config XEN_BLKDEV_TAP space. Odds are that you want to say N here. config XEN_WRITABLE_PAGETABLES - bool + bool "writable page tables" default y +config XEN_SYSCALL_STATS + bool "system call statistics" + default n + +config XEN_DEBUG_NO_MMU_BATCHING + bool "Disables batching on MMU updates" + default n + help + This does a hypercall per PTE update + we only use this for benchmarking + enable only if you know what you are doing + +config XEN_BATCH_MODE1 + bool "A variant of writable pagetable using the batch interface" + default n + help + default is no batching and minor mods for some batching + we only use this for benchmarking + enable only if you know what you are doing + +config XEN_BATCH_MODE2 + bool "forward port of 2.4 batching" + default n + help + default is batching + flushes where 2.4 had them + we only use this for benchmarking + enable only if you know what you are doing + + config XEN_SCRUB_PAGES bool "Scrub memory before freeing it to Xen" default y diff --git a/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/Makefile b/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/Makefile index 1542958464..13be9fb397 100644 --- a/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/Makefile +++ b/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/Makefile @@ -43,6 +43,8 @@ c-obj-$(CONFIG_HPET_TIMER) += time_hpet.o c-obj-$(CONFIG_EFI) += efi.o efi_stub.o c-obj-$(CONFIG_EARLY_PRINTK) += early_printk.o +c-obj-$(CONFIG_XEN_SYSCALL_STATS) += syscall_stats.o + EXTRA_AFLAGS := -traditional c-obj-$(CONFIG_SCx200) += scx200.o diff --git a/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/entry.S b/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/entry.S index db26c6a440..80fbaa5633 100644 --- a/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/entry.S +++ b/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/entry.S @@ -280,7 +280,10 @@ sysenter_past_esp: jnz syscall_trace_entry cmpl $(nr_syscalls), %eax jae syscall_badsys - call *sys_call_table(,%eax,4) +#ifdef CONFIG_XEN_SYSCALL_STATS + lock incl syscall_stats(,%eax,4) +#endif + call *sys_call_table(,%eax,4) movl %eax,EAX(%esp) cli movl TI_flags(%ebp), %ecx @@ -305,7 +308,10 @@ ENTRY(system_call) cmpl $(nr_syscalls), %eax jae syscall_badsys syscall_call: - call *sys_call_table(,%eax,4) +#ifdef CONFIG_XEN_SYSCALL_STATS + lock incl syscall_stats(,%eax,4) +#endif + call *sys_call_table(,%eax,4) movl %eax,EAX(%esp) # store the return value syscall_exit: XEN_BLOCK_EVENTS(%esi) # make sure we don't miss an interrupt diff --git a/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/syscall_stats.c b/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/syscall_stats.c new file mode 100644 index 0000000000..e614a316f9 --- /dev/null +++ b/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/syscall_stats.c @@ -0,0 +1,91 @@ +/* -*- Mode:C; c-basic-offset:4; tab-width:4 -*- + **************************************************************************** + * (C) 2005 - Rolf Neugebauer - Intel Research Cambridge + **************************************************************************** + * + * File: syscall_stats.c + * Author: Rolf Neugebauer (rolf.neugebauer@intel.com) + * Date: Mar 2005 + * + * Description: add a proc interface to get per system call stats + */ + + +#include +#include +#include +#include + +unsigned long syscall_stats[NR_syscalls]; +static unsigned char foobar[4]; + +/* a write just resests the counter */ +static ssize_t syscall_write(struct file *f, const char *data, + size_t size, loff_t *pos) +{ + printk("resetting syscall stats\n"); + memset(&syscall_stats, 0, sizeof(syscall_stats)); + return size; +} + +static int show_syscall(struct seq_file *m, void *v) +{ + int i; + for ( i=0; iproc_fops = &proc_syscall_operations; + else + printk("Unable to create /proc/syscalls.\n"); + return 0; +} +subsys_initcall(syscall_stats_init); diff --git a/linux-2.6.10-xen-sparse/arch/xen/i386/mm/hypervisor.c b/linux-2.6.10-xen-sparse/arch/xen/i386/mm/hypervisor.c index 9068960f05..b9786ff8f4 100644 --- a/linux-2.6.10-xen-sparse/arch/xen/i386/mm/hypervisor.c +++ b/linux-2.6.10-xen-sparse/arch/xen/i386/mm/hypervisor.c @@ -133,6 +133,9 @@ void queue_l1_entry_update(pte_t *ptr, unsigned long val) per_cpu(update_queue[idx], cpu).ptr = virt_to_machine(ptr); per_cpu(update_queue[idx], cpu).val = val; increment_index(); +#ifdef CONFIG_XEN_DEBUG_NO_MMU_BATCHING + __flush_page_update_queue(); +#endif spin_unlock_irqrestore(&update_lock, flags); } diff --git a/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/pgtable-2level.h b/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/pgtable-2level.h index 3abd3ce14a..8c1a53ee75 100644 --- a/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/pgtable-2level.h +++ b/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/pgtable-2level.h @@ -36,7 +36,16 @@ do { \ #endif #define set_pte_atomic(pteptr, pteval) set_pte(pteptr, pteval) #else +#if defined(CONFIG_XEN_DEBUG_NO_MMU_BATCHING) +#define set_pte(pteptr, pteval)\ + set_pte_batched(pteptr, pteval) +#elif defined(CONFIG_XEN_BATCH_MODE) +#define set_pte(pteptr, pteval)({\ + set_pte_batched(pteptr, pteval);\ + _flush_page_update_queue();}) +#else #define set_pte(pteptr, pteval) (*(pteptr) = pteval) +#endif #define set_pte_atomic(pteptr, pteval) set_pte(pteptr,pteval) #endif /* diff --git a/linux-2.6.10-xen-sparse/mm/memory.c b/linux-2.6.10-xen-sparse/mm/memory.c index cd10d79d94..67ad006621 100644 --- a/linux-2.6.10-xen-sparse/mm/memory.c +++ b/linux-2.6.10-xen-sparse/mm/memory.c @@ -218,6 +218,11 @@ out: * dst->page_table_lock is held on entry and exit, * but may be dropped within pmd_alloc() and pte_alloc_map(). */ +#ifdef CONFIG_XEN_BATCH_MODE1 +#undef set_pte +#define set_pte(pteptr, pteval)\ + set_pte_batched(pteptr, pteval); +#endif int copy_page_range(struct mm_struct *dst, struct mm_struct *src, struct vm_area_struct *vma) { @@ -354,8 +359,11 @@ cont_copy_pte_range_noset: cond_resched_lock(&dst->page_table_lock); cont_copy_pmd_range: src_pmd++; - dst_pmd++; + dst_pmd++; } while ((unsigned long)src_pmd & PMD_TABLE_MASK); +#ifdef CONFIG_XEN_BATCH_MODE1 + _flush_page_update_queue(); +#endif } out_unlock: spin_unlock(&src->page_table_lock); @@ -445,9 +453,19 @@ static void zap_pte_range(struct mmu_gather *tlb, free_swap_and_cache(pte_to_swp_entry(pte)); pte_clear(ptep); } +#ifdef CONFIG_XEN_BATCH_MODE1 + _flush_page_update_queue(); +#endif pte_unmap(ptep-1); } +#ifdef CONFIG_XEN_BATCH_MODE1 +#undef set_pte +#define set_pte(pteptr, pteval)\ + set_pte_batched(pteptr, pteval);\ + _flush_page_update_queue() +#endif + static void zap_pmd_range(struct mmu_gather *tlb, pgd_t * dir, unsigned long address, unsigned long size, struct zap_details *details) @@ -839,6 +857,11 @@ out: EXPORT_SYMBOL(get_user_pages); +#ifdef CONFIG_XEN_BATCH_MODE1 +#undef set_pte +#define set_pte(pteptr, pteval)\ + set_pte_batched(pteptr, pteval); +#endif static void zeromap_pte_range(pte_t * pte, unsigned long address, unsigned long size, pgprot_t prot) { @@ -855,7 +878,18 @@ static void zeromap_pte_range(pte_t * pte, unsigned long address, address += PAGE_SIZE; pte++; } while (address && (address < end)); + +#ifdef CONFIG_XEN_BATCH_MODE1 + _flush_page_update_queue(); +#endif + } +#ifdef CONFIG_XEN_BATCH_MODE1 +#undef set_pte +#define set_pte(pteptr, pteval)\ + set_pte_batched(pteptr, pteval);\ + _flush_page_update_queue() +#endif static inline int zeromap_pmd_range(struct mm_struct *mm, pmd_t * pmd, unsigned long address, unsigned long size, pgprot_t prot) @@ -917,6 +951,11 @@ int zeromap_page_range(struct vm_area_struct *vma, unsigned long address, unsign * mappings are removed. any references to nonexistent pages results * in null mappings (currently treated as "copy-on-access") */ +#ifdef CONFIG_XEN_BATCH_MODE1 +#undef set_pte +#define set_pte(pteptr, pteval)\ + set_pte_batched(pteptr, pteval); +#endif static inline void remap_pte_range(pte_t * pte, unsigned long address, unsigned long size, unsigned long pfn, pgprot_t prot) { @@ -934,7 +973,16 @@ static inline void remap_pte_range(pte_t * pte, unsigned long address, unsigned pfn++; pte++; } while (address && (address < end)); +#ifdef CONFIG_XEN_BATCH_MODE1 + _flush_page_update_queue(); +#endif } +#ifdef CONFIG_XEN_BATCH_MODE1 +#undef set_pte +#define set_pte(pteptr, pteval)\ + set_pte_batched(pteptr, pteval);\ + _flush_page_update_queue() +#endif static inline int remap_pmd_range(struct mm_struct *mm, pmd_t * pmd, unsigned long address, unsigned long size, unsigned long pfn, pgprot_t prot) diff --git a/tools/misc/Makefile b/tools/misc/Makefile index 39b38c25c1..3b533e5dc4 100644 --- a/tools/misc/Makefile +++ b/tools/misc/Makefile @@ -14,7 +14,7 @@ CFLAGS += $(INCLUDES) HDRS = $(wildcard *.h) -TARGETS = xenperf +TARGETS = xenperf xc_shadow INSTALL_BIN = $(TARGETS) xencons INSTALL_SBIN = netfix xm xend xensv xenperf diff --git a/tools/misc/cpuperf/cpuperf.c b/tools/misc/cpuperf/cpuperf.c index 4e4dbb0665..093cde556d 100644 --- a/tools/misc/cpuperf/cpuperf.c +++ b/tools/misc/cpuperf/cpuperf.c @@ -246,7 +246,7 @@ int main(int argc, char **argv) while((cpu_mask&1)) { int i; for (i=0x300;i<0x312;i++) { - printf("%010llx ",cpus_rdmsr( cpu_mask, i ) ); + printf("%010llu ",cpus_rdmsr( cpu_mask, i ) ); } printf("\n"); cpu_mask>>=1; diff --git a/tools/misc/xc_shadow.c b/tools/misc/xc_shadow.c new file mode 100644 index 0000000000..ba21a34126 --- /dev/null +++ b/tools/misc/xc_shadow.c @@ -0,0 +1,70 @@ +/* -*- Mode:C; c-basic-offset:4; tab-width:4 -*- + **************************************************************************** + * (C) 2005 - Rolf Neugebauer - Intel Research Cambridge + **************************************************************************** + * + * File: xc_shadow.c + * Author: Rolf Neugebauer (rolf.neugebauer@intel.com) + * Date: Mar 2005 + * + * Description: + */ + + +#include +#include +#include +#include +#include +#include + +void usage() +{ + printf("xc_shadow: -[0|1|2]\n"); + printf(" set shadow mode\n"); + exit(0); +} + +int main(int argc, char *argv[]) +{ + int xc_handle; + int mode; + + if ( argc > 1 ) + { + char *p = argv[1]; + if (*p++ == '-') { + if (*p == '1') + mode = 1; + else if (*p == '2') + mode = 2; + else if (*p == '0') + mode = 0; + else + usage(); + } else + usage(); + } + else + usage(); + + if ( (xc_handle = xc_interface_open()) == -1 ) + { + fprintf(stderr, "Error opening xc interface: %d (%s)\n", + errno, strerror(errno)); + return 1; + } + + if ( xc_shadow_control(xc_handle, + 0, + mode, + NULL, + 0, + NULL) < 0 ) + { + fprintf(stderr, "Error reseting performance counters: %d (%s)\n", + errno, strerror(errno)); + return 1; + } + return 0; +} -- 2.30.2